<?php

namespace Modules\Car\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class IllegalRecord extends Model
{
    use HasFactory;
    protected $appends = ['diff_time'];
    protected $guarded = [];

    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }
    public function getDiffTimeAttribute()
    {
        $start = new Carbon($this->fetch_time);
        $end = new Carbon($this->return_time);
        return $start->diff($end)->days;
    }
}
